function xsr() {
  var e = {}, t = 1e4;
  switch (arguments.length) {
    case 1:
      var n = arguments[0];
      typeof n == "object" && wx.request({
        url: n.url,
        method: n.method,
        header: { "content-type": "application/json" },
        success: n.success,
        fail: n.error,
        complete: n.complete
      });
      break;
    case 2:
      var n = arguments[0], r = arguments[1];
      typeof n == "string" && typeof r == "function" ? wx.request({
        url: n,
        method: "GET",
        header: { "content-type": "application/json" },
        success: r,
        fail: n.error,
        complete: n.complete
      }) : typeof n == "object" && typeof r == "function" && (loading(), wx.request({
        url: n.url,
        method: "POST", data: isNull(Encrypt(n.postData)) ? "" : { data: Encrypt(JSON.stringify(n.postData)) },
        header: { "content-type": "application/json" },
        success: function (e) {

          hideloading(),
            n.isCache ? r(JSON.parse(e.data.d)) : n.postData.isCache ? r(JSON.parse(e.data)) : r(JSON.parse(Decrypt(e.data)))
          // r(e.data)
        },
        fail: function (e) {
          console.error("错误信息:", e)
        },
        complete: n.complete
      }));
      break;
    default:
  }
}

function loading(e, t, n) {
  wx.showLoading({ mask: !0, title: e || "loading...", success: n })
}

function hideloading() {
  var e = setTimeout(function () {
    wx.hideLoading()
  }, 1e3)
}



module.exports = {
  xsr: xsr,
  loading: loading,
  hideloading: hideloading,
};